package cn.net.dpi.util;

import cn.hutool.core.util.ArrayUtil;

import java.time.LocalDateTime;

/**
 * Copyright(c) 2021 Dayou Positioning Intelligence Co.,Ltd
 * All rights reserved.
 *
 * 参数判断工具类
 *
 * @Date 2022/1/7
 * @Author changguoshan (changguoshan@dayoupi.cn)
 * @Version 0.2
 * @Reviewer
 */
public class ObjectUtil {

    /**
     * 参数判断，参数可以同时为空，当有参数不为空时就全部都不能为空
     * @param obj
     * @return
     */
    public static boolean concurrence(Object... obj){
         if (ArrayUtil.isAllNull(obj)){
             return true;
         }
        boolean aNull = ArrayUtil.hasNull(obj);
         if (aNull){
             return false;
         }
         boolean isAllTimeType=true;
        for (int i = 0; i < obj.length; i++) {
            if (!(obj[i] instanceof LocalDateTime)){
                isAllTimeType=false;
            }
        }
         if (obj.length==2&&isAllTimeType){
             LocalDateTime startTime = (LocalDateTime) obj[0];
             LocalDateTime endTime = (LocalDateTime) obj[1];
             if (startTime.isBefore(endTime)){
                 return true;
             }
         }
         return false;
    }
}
